import React, { useState, useEffect } from 'react'
import axios from 'axios'
import { Cell,Dialog,Toast,Divider } from 'react-vant';
import { Passed } from '@react-vant/icons'
import { history } from 'umi'
import HeaderNav from '../../../../components/ayq/HeaderNav'
import './index.less'

export default function Settings() {
  let [cache,setcache] = useState(true)
  const [visible, setVisible] = useState(false)
  const clear = () =>{
    setcache(false)
    setVisible(false)
    Toast({
      message: '清除成功',
      icon: <Passed  />,
    })
  }
  return (
    <div className='settings'>
      <HeaderNav title="设置" />
      <div className='body'>
        <Divider style={{margin:0}}/>
        <Cell title='头像' onClick={()=>{}} isLink>
          <img src="" alt="" />
        </Cell>
        <Cell title='手机号' isLink />
        <Cell title='推送设置' onClick={()=>history.push('/push')} isLink />
        <Cell title='清楚缓存' onClick={()=>setVisible(true)} isLink value={cache && '12M'} />
        <Cell title='检查更新' onClick={() => Toast.info('目前为最新版本')} isLink />
      </div>
      <div className='btom'>
        <button onClick={() => form1.submit()}>退出登录</button>
      </div>
      <Dialog
        visible={visible}
        title='您确定要清除本地缓存吗？'
        showCancelButton
        onConfirm={() => clear()}
        onCancel={() => setVisible(false)}
      ></Dialog>
    </div>
  )
}
